package com.utils;


import lombok.extern.slf4j.Slf4j;

import java.util.List;
import java.util.Map;
@Slf4j
public class TxtDataInserUtil {

    public static void main(String[] args) {
//        String path="D:\\工作文档\\sinobase\\需求文档\\呼叫中心\\ATLAS";
        String path="D:\\工作文档\\sinobase\\需求文档\\呼叫中心\\GMDB";

        String dbName="FRD";
        String dburl="jdbc:mysql://localhost:3228/FRD?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true";
        String dbUserName="root";
        String psd="Sinobase@123";
        List<String> strings = MysqlDbUtil.showTables(dburl, dbUserName, psd);
        final Map<String, List<Map<String, Object>>> info = TxtFileReadUtils.getInfo(path);
        info.entrySet().forEach(entry->{
              String tableName = entry.getKey().replace("_"," ").trim();

              if(strings.contains(tableName)) {
                  List<Map<String, Object>> value = entry.getValue();
                  MysqlDbUtil.bitchInsert(value,dburl, dbUserName, psd,tableName);
              }else{
                  log.info("文件 {} 未找到与之对应数据库",tableName);
              }
        });
    }
}
